package com.wuming.caiwu.service;


import com.wuming.caiwu.core.BusinessException;
import com.wuming.caiwu.model.SysPermission;

import java.util.List;
import java.util.Map;

/**
 * 系统菜单服务
 * Created by hanfei on 16/4/19.
 */
public interface SysPermissionService {

    /**
     * 保存菜单信息
     *
     * @param member 菜单信息
     * @throws BusinessException
     */
    void saveSysPermission(SysPermission member) throws BusinessException;

    /**
     * 更新菜单信息
     *
     * @param member 菜单信息
     * @throws BusinessException
     */
    void modifySysPermission(SysPermission member) throws BusinessException;

    /**
     * 根据id查询菜单信息
     *
     * @param id 菜单id
     * @return 菜单信息
     * @throws BusinessException
     */
    SysPermission getSysPermissionById(Long id) throws BusinessException;

    /**
     * 根据id删除菜单信息
     *
     * @param id 菜单id
     * @throws BusinessException
     */
    void removeSysPermissionById(Long id) throws BusinessException;


    /**
     * 分页查询菜单列表
     *
     * @param name  菜单名
     * @param pageIndex     当前页
     * @param pageSize      每页条数
     * @return 菜单列表
     * @throws BusinessException
     */
    List<SysPermission> getSysPermissionsByPage(String name, int pageIndex, int pageSize) throws BusinessException;

    /**
     * 查询总的菜单数
     *
     * @param name  菜单名
     * @return 菜单总数
     * @throws BusinessException
     */
    int getTotal(String name) throws BusinessException;

    /**
     * 查询所有的系统权限
     * @return 系统权限
     * @throws BusinessException
     */
    List<SysPermission> getSysPermission(Long pid) throws BusinessException;

    List<SysPermission> buildSysPermission(List<SysPermission> permissions);

    List<SysPermission> getPermissionByRoleId(Long roleId) throws BusinessException;

    boolean isHasPermission(SysPermission current,List<SysPermission> rolePermissions);

    int removePermissionByRoleId(Long roleId) throws BusinessException;

    int saveRolePermission(Long roleId,String checkedData) throws BusinessException;

    List<SysPermission> getPermissionByUserId(Long userId) throws BusinessException;

    Map<String,List<SysPermission>> buidPermissionTree(List<SysPermission> permissions);

}
